<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-1.11.1.js"></script>
    <script src="jquery.validate.js"></script>
    <style>
        .error{
            color: red;
        }
    </style>
</head>
<body>
<form action="xxx">
    <p>用户名: <input type="text" name="username" required minlength="6"></p>
    <p>密码: <input type="password" name="pwd1" required minlength="6" maxlength="8"></p>
    <p>确认密码: <input type="password" name="pwd2" equalTo=":password[name=pwd1]"></p>
    <p><input type="submit" value="提交"></p>
</form>
<script>
    $('form').validate({
        messages:{
            username:{
                required:'用户名是必须的',
                minlength:'用户名至少为6位'
            },
            pwd1:{
                required:'用户名是必须的',
                minlength:'用户名至少为6位',
                maxlength:'用户名最多为8位'
            },
            pwd2:{
                equalTo:'必须与密码相同'
            }
        }
    })
</script>
</body>
</html>
